<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <base href="{$Think.const.BASE_PATH}">
    <title>影片添加</title>
    <!--引入头部meta文件 -->
    {include file="./application/index/view/index/head_meta.html" /}
    <!--引入头部link(css)文件 -->
    {include file="./application/index/view/index/head_link.html" /}
    <!--引入头部script文件 -->
    {include file="./application/index/view/index/head_script.html" /}
    <link rel="stylesheet" href="public/static/css/manager/catalog.css?v={$Think.const.NOW_TIME}" type="text/css">
    <!--=====================JS_Link===========================-->

</head>
<body>
<!--内容 START-->
{include file="manager/menu"/}
<div class="container">
    <div class="row">
        <div class="col-sm-3">
            <div class="row">
                <!--引入导航html文件 -->
                {include file="manager/navigate"/}
            </div>
        </div>
        <div class="col-sm-9">

            <!-- Nav tabs -->
            <ul class="nav nav-tabs" role="tablist">
                <li class="nav-item">
                    <a class="nav-link active" data-toggle="tab" href="#home">目录</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" data-toggle="tab" href="#menu1">地区年代</a>
                </li>
            </ul>

            <!-- Tab panes -->
            <div class="tab-content">
                <div id="home" class="tab-pane active">
                    <div class="row">
                        <div class="form-control" style="text-align: center;">
                            <span style="color: blue;">一级目录：</span>
                            <div contenteditable="true" class="catalog_name" style="display: inline-block;"></div>
                            <select class="isVip_catalog" id="isVip_catalog">
                                <option value="0">普通用户</option>
                                <option value="1">会员用户</option>
                            </select>
                            <a href="javascript:;" class="add_CataLog_btn btn">添加</a>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-sm-6" style="text-align: center;">
                            <span style="color:green;">二级目录：</span>
                            <select class="cataLog_id">
                                {volist name="cataLogList" id="cataLogList_var"}
                                <option value="{$cataLogList_var.id}">{$cataLogList_var.name}</option>
                                {/volist}
                            </select>

                            <div class="form-control">
                                <div contenteditable="true" class="subClass_name" style="display: inline-block;"></div>
                                <a href="javascript:;" class="add_SubClass_btn btn">添加</a>
                            </div>
                        </div>
                        <div class="col-sm-6" style="text-align: center;">
                            <span style="color: #fd5c11;">类型：</span>
                            <select class="cataLog_id_subClass">
                                {volist name="cataLogList" id="cataLogList_var"}
                                <option value="{$cataLogList_var.id}">{$cataLogList_var.name}</option>
                                {/volist}
                            </select>
                            <select class="subClass_id"></select>

                            <div class="form-control">
                                <div contenteditable="true" class="type_name" style="display: inline-block;"></div>
                                <a href="javascript:;" class="add_Type_btn btn">添加</a>
                            </div>
                        </div>
                    </div>
                    <div class="col catalog-title"><span style="color:blue;">一级目录</span><span>--></span><span style="color:green;">二级目录</span><span>--></span><span style="color:#fd5c11;">类型</span></div>

                    <div class="form-control" style="border:1px solid #f7dde0;background: #f7dde0;">
                        {volist name="cataLogList" id="list"}
                        <span style="color:blue;">{$list.name}</span><br/>
                        {volist name="$list.subClassList" id="li"}
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:green;">{$li.name}</span><span>--></span>
                        {volist name="typeList" id="l"}
                        {if condition ="$l.subClass.id eq $li.id"}
                        <span style="color:#fd5c11;">{$l.name}</span>
                        {/if}
                        {/volist}
                        <br/>
                        {/volist}
                        <br/>
                        {/volist}
                    </div>
                </div>
                <div id="menu1" class="tab-pane fade">
                    <div class="row">
                        <div class="form-control" style="text-align: center;">
                            <span>地区</span>
                            <div contenteditable="true" class="loc_name" style="display: inline-block;"></div>
                            <a href="javascript:;" class="add_Loc_btn btn" >添加</a>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-sm-6">
                            <div class="form-control" style="text-align: center;">
                                <span>级别</span>
                                <div contenteditable="true" class="level_name" style="display: inline-block;"></div>
                                <a href="javascript:;" class="add_Level_btn btn">添加</a>
                            </div>
                        </div>

                        <div class="col-sm-6">
                            <div class="form-control" style="text-align: center;">
                                <span>年代</span>
                                <div contenteditable="true" class="decade_name" style="display: inline-block;"></div>
                                <a href="javascript:;" class="add_Decade_btn btn">添加</a>
                            </div>
                        </div>
                    </div>


                    <div class="col catalog-title"><span style="color:blue;">地区</span><span>/</span><span style="color:green;">级别</span><span>/</span><span style="color:#fd5c11;">年代</span></div>
                    <div class="form-control" style="border:1px solid #f7dde0;background: #f7dde0;">
                        <span>地区--></span>
                        {volist name="locList" id="locList_list"}
                        <span style="color:blue;">{$locList_list.name}</span>
                        {/volist}
                        <br/>
                        <span>级别--></span>
                        {volist name="levelList" id="levelList_list"}
                        <span style="color:green;">{$levelList_list.name}</span>
                        {/volist}
                        <br/>

                        <span>年代--></span>
                        {volist name="decadeList" id="decadeList_list"}
                        <span style="color:#fd5c11;">{$decadeList_list.name}</span>
                        {/volist}
                        <br/>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
    <script>
        $(function () {
            $(".add_CataLog_btn").click(function () {
                var catalog_name = $(".catalog_name").text();
                var isVip_catalog = $(".isVip_catalog").val();
                if(catalog_name!="" && catalog_name){
                    $.ajax({
                        url: "{:url('manager/addCataLog')}",
                        type: "POST",
                        dataType: "json",
                        data: "name=" + catalog_name+"&isVip="+isVip_catalog,
                        success: backFunction,
                        error: function () {
                            alert("系统繁忙!");
                        }
                    });
                }else{
                    alert("字段为空！");
                }
            });

            $(".add_SubClass_btn").click(function () {
                var subClass_name = $(".subClass_name").text();
                if(subClass_name!="") {
                    $.ajax({
                        url: "{:url('manager/addSubClass')}",
                        type: "POST",
                        dataType: "json",
                        data: "cataLog_id=" + $(".cataLog_id").val() + "&name=" + subClass_name,
                        success: backFunction,
                        error: function () {
                            alert("系统繁忙!");
                        }
                    });
                }else{
                    alert("字段为空！");
                }
            });

            $(".add_Type_btn").click(function () {
                var type_name = $(".type_name").text();
                debugger;
                if(type_name!=""){
                    $.ajax({
                        url: "{:url('manager/addType')}",
                        type: "POST",
                        dataType: "json",
                        data: "subClass_id=" + $(".subClass_id").val() + "&name=" + type_name,
                        success: backFunction,
                        error: function () {
                            alert("系统繁忙!");
                        }
                    });
                }else{
                    alert("字段为空！");
                }
            });

            $(".add_Loc_btn").click(function () {
                var loc_name = $(".loc_name").text();
                if(loc_name!=""){
                    $.ajax({
                        url: "{:url('manager/addLoc')}",
                        type: "POST",
                        dataType: "json",
                        data: "name=" + $(".loc_name").text(),
                        success: backFunction,
                        error: function () {
                            alert("系统繁忙!");
                        }
                    });
                }else{
                    alert("字段为空！");
                }
            });

            $(".add_Level_btn").click(function () {
                var level_name = $(".level_name").text();
                if(level_name!="") {
                    $.ajax({
                        url: "{:url('manager/addLevel')}",
                        type: "POST",
                        dataType: "json",
                        data: "name=" + $(".level_name").text(),
                        success: backFunction,
                        error: function () {
                            alert("系统繁忙!");
                        }
                    });
                }else{
                    alert("字段为空！");
                }
            });

            $(".add_Decade_btn").click(function () {
                var decade_name = $(".decade_name").text();
                if(decade_name!="") {
                    $.ajax({
                        url: "{:url('manager/addDecade')}",
                        type: "POST",
                        dataType: "json",
                        data: "name=" + $(".decade_name").text(),
                        success: backFunction,
                        error: function () {
                            alert("系统繁忙!");
                        }
                    });
                }else{
                    alert("字段为空！");
                }
            });

            $(".cataLog_id_subClass").change(function () {
                var catalog_id = $(this).val();
                $.ajax({
                    url: "{:url('manager/getSubClass')}",
                    type: "post",
                    dataType: "json",
                    data: "catalog_id=" + catalog_id,
                    success: function (data) {
                        $(".subClass_id").find("option").remove();
                        var jss = data;
                        for (var i = 0; i < jss.length; i++) {
                            var op = "<option value='" + jss[i].id + "'>" + jss[i].name + "</option>";
                            $(".subClass_id").append($(op));
                        }
                    },
                    error: function () {
                        alert("系统繁忙!");
                    }
                });
            });

            $.ajax({
                url: "{:url('manager/getSubClass')}",
                type: "POST",
                dataType: "json",
                data: "catalog_id=" + $(".cataLog_id_subClass").val(),
                success: function (data) {
                    var jss = data;
                    for (var i = 0; i < jss.length; i++) {
                        var op1 = "<option value='" + jss[i].id + "'>" + jss[i].name + "</option>";
                        $(".subClass_id").append($(op1));
                    }
                },
                error: function () {
                    alert("系统繁忙!");
                }
            });
        })

        function backFunction(data) {
            if (data != "0") {
                location.reload();
            }
        }
    </script>
</body>
</html>